/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.apt.citytag.process;

import com.apt.countrytag.*;
import com.apt.hobbiestag.process.*;
import com.apt.professionaltag.Process.*;
import com.apt.tag.Connect_DB;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Bach
 */
public class EnableCity {

    public static boolean setEnableCity(String city_Name, String country_Id) {

        String up = "UPDATE [Matrimony].[dbo].[Cities]\n"
                + "   SET [City_Status] = 1 \n"
                + " WHERE [City_Name]=? and [Country_Id]=? ";
        boolean re = false;
        Connection con = null;
        PreparedStatement ps = null;
        try {
            con = Connect_DB.getConnection();
            con.setAutoCommit(false);// transaction
            ps = con.prepareStatement(up);
            ps.setString(1, city_Name);
            ps.setInt(2, Integer.parseInt(country_Id));
            int i = ps.executeUpdate();
            if (i > 0) {
                re = true;
            }
            con.commit();
        } catch (SQLException e) {
            e.printStackTrace();
            try {
                con.rollback();
            } catch (SQLException ex) {
                Logger.getLogger(DisableHobbies.class.getName()).log(Level.SEVERE, null, ex);
            }
        } finally {
            Connect_DB.close(null, null, ps, con);
        }
        return re;
    }

  
}
